/**
 * Created by henian.xu on 2017/6/30 0030.
 *
 */

var
  gulp = require('gulp'),
  sourcemaps = require('gulp-sourcemaps'),
  sass = require('gulp-sass'),
  postcss = require('gulp-postcss'),
  autoprefixer = require('autoprefixer'),
  cssnano = require('cssnano');

var
  cfg = {
    sass: {
      src: './src/style/**/**.scss',
      dest: './static/css'
    }
  };

gulp.task('B:sass', function () {
  var plugins = [
    autoprefixer({browsers: ['ie >= 8', '> 1%', 'last 3 version']}),
    cssnano()
  ];

  return gulp.src(cfg.sass.src)
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(postcss(plugins))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(cfg.sass.dest));
});

gulp.task('W:all', function () {
  gulp.watch([cfg.sass.src], ['B:sass']);
});

